package com.ssyt.hiring.web.dao;

import org.springframework.stereotype.Repository;

import com.ssyt.cdp.common.BaseDao;
import com.ssyt.hiring.entity.CompanyEntity;

@Repository
public class CompanyDao extends BaseDao<CompanyEntity, Integer> {
	/**
	 * 公司注册
	 * 
	 * @param company
	 */
	public void companyregister(CompanyEntity company) {
		save(company);
	}

	/**
	 * 公司登录
	 * 
	 * @param company
	 * @return
	 */
	public CompanyEntity companyLogin(CompanyEntity company) {
		String hql = "FROM CompanyEntity WHERE code=? and password=?";
		return uniqueEntityByHql(hql, company.getCode(), company.getPassword());
	}

	/**
	 * 企业信息查询
	 * 
	 * @param companyId
	 * @return
	 */
	public CompanyEntity getInfoCompany(int companyId) {
		String hql = "from CompanyEntity where id =?";
		return uniqueEntityByHql(hql, companyId);

	}

	/**
	 * 企业信息修改
	 * 
	 * @param company
	 */
	public void updateInfoCompany(CompanyEntity company) {
		update(company);
	}

	public boolean checkCompanyCode(String code) {
		String hql = "FROM CompanyEntity WHERE code=?";
		CompanyEntity company = uniqueEntityByHql(hql, code);
		if (company != null) {
			return false;
		}
		return true;
	}
}
